<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/common.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="title">
        Course List
    </ui:define>

    <ui:define name="head">
          <link rel="stylesheet" href="../../res/css/admin-style.css"/>
    </ui:define>

    <ui:define name="pageheader">
        Course list
    </ui:define>

    <ui:define name="content">
        <h:form id="mainform">


            <h:dataTable styleClass="main-table" value="#{courseManager.allCourse}" var="s" width="100%" cellpadding="0" border="0">
                
                
                <h:column headerClass="table-header-repeat line-left minwidth-1">
                    <f:facet name="header">
                        <h:commandLink value="ID" />
                    </f:facet>
                    #{s.courseId}
                </h:column>
                <h:column headerClass="table-header-repeat line-left minwidth-1">
                    <f:facet name="header">
                        <h:commandLink value="Center" />
                    </f:facet>
                    #{s.centers.name}
                </h:column>
                <h:column headerClass="table-header-repeat line-left minwidth-1">
                    <f:facet name="header">
                        <h:commandLink value="Name" />
                    </f:facet>
                    #{s.name}
                </h:column>
                <h:column headerClass="table-header-repeat line-left minwidth-1">
                    <f:facet name="header">
                        <h:commandLink value="Start date" />
                    </f:facet>
                    <h:outputText value="#{s.startDate}">
                        <f:convertDateTime type="date" pattern="dd-MM-yyyy" timeZone="GMT+7"/>
                    </h:outputText>
                </h:column>
                 <h:column headerClass="table-header-repeat line-left minwidth-1">
                    <f:facet name="header">
                        <h:commandLink value="End date" />
                    </f:facet>
                     <h:outputText value="#{s.endDate}">
                         <f:convertDateTime type="date" pattern="dd-MM-yyyy" timeZone="GMT+7"/>
                    </h:outputText>
                </h:column>
                 <h:column headerClass="table-header-repeat line-left minwidth-1">
                    <f:facet name="header">
                        <h:commandLink value="Status" />
                    </f:facet>

                     <h:selectOneMenu value="#{s.status}"  label="#{courseStatus.getDisplayName(s.status)}">
                         <f:selectItems value="#{courseStatus.all}" var="st" itemLabel="#{st.display}" itemValue="#{st.value}"  />
                     </h:selectOneMenu>
                     <h:commandButton value="Set status" action="#{courseManager.updateStatus(s)}" />
                </h:column>
                <h:column headerClass="table-header-options line-left">
                    <f:facet name="header" >
                        Options
                    </f:facet>
                    <h:commandLink action="#{courseManager.edit(s)}" class="icon-1 info-tooltip"  />
                    <h:commandLink action="#{courseManager.remove(s)}" styleClass="icon-2 info-tooltip" />
                    <h:commandLink action="#{courseManager.pickStudent(s)}" class="icon-5 info-tooltip" />
                    <h:commandLink action="#{courseManager.pickStaff(s)}" class="icon-5 info-tooltip" />
                </h:column>

            </h:dataTable>

            <h:commandButton action="course-create" value="Add"/>
        </h:form>
    </ui:define>

</ui:composition>
